package oralExamSchedulingSystem;

import java.util.ArrayList;
import java.util.Date;

public class Group 
{	
	private String _roomNumber;
	private int _groupId;
	private Time _examTime; 
	private String _subject;
	private ArrayList<Student> _student;
	private int _groupMax;
	
	public Group(String roomNum,int groupId,Time examTime,String subject,int groupMax){
		this._roomNumber=roomNum;
		this._groupId=groupId;
		this._examTime=examTime;
		this._subject=subject;
		this._groupMax=groupMax;
		this._student=new ArrayList<Student>();
	}
	
	public boolean isFull(){
		if(_groupMax<=_student.size())
			return true;
		return false;
	}
	

	public boolean isCollideWith(Group that_group){
		if (this._examTime.isCollideWith(that_group.gettime()))
				return true;
			return false;

	}
	

	public String toString(){
		return "Group"+_groupId+"{"+_roomNumber+" "+_examTime+" "+_student+"}";
	}
	
	public  boolean setStudentList(ArrayList<Student> studentList){
		if(studentList.size()>_groupMax)
			return false;
		_student=studentList;
		return true;
	}
	

	public boolean addStudent(Student student){
		if (this.isFull())
			return false;
		else{
			this._student.add(student);
			student.assignedTo(this);
			return true;
		}
	}
	
	public int getGroupID(){
		return _groupId;
	}
	
	public Time gettime(){
		return this._examTime.getthis();
	}
	
	
	

}